import 'package:flutter/material.dart';
import 'package:helloflutter/page/search.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("DEmo"),
        ),
        body: const HomePage(),
      ),
    );
  }
}

//有状态组件！！！
class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int count = 0;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        const SizedBox(
          height: 30,
        ),
        Chip(
          label: Text("$count"),
        ),
        const SizedBox(
          height: 20,
        ),
        RaisedButton(
            child: const Text("Hello Btn !!!"),
            onPressed: () {
              setState(() {
                count++;
              });
            }),
        const SizedBox(
          height: 20,
        ),
        RaisedButton(
          child: const Text("跳转到搜索页面"),
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(builder: (context)=>const SearchPage()),
            );
          },
        ),
      ],
    );
    return const Center(child: Text("state"));
  }
}
